ria.extraItemCommands = {
    callRemove : function(spec, json) {
        JsonC.callSfAction(spec.extra.removeAction, {id:spec.ds.id,"jsObjName":spec.extra._jsObjName});
    },
    remove : function(spec, json) {
        spec.extra._list.removeItemById(spec.ds.id);
    },
    submit : function(spec, json) {
        JsonC.submitForSfAction(spec.extra.editAction, {}, spec.ds._formId);
    },
    postDisplay : function(spec, json) {
        var selector = '#' + spec.ds._formId + " :checkbox.checktrue";
        $(selector).attr("checked",true);
    },
    showFormError : function(spec, json) {
        //json.fieldName
        //json.message
        console.log('aaa');
        console.log(spec.extraTplValues);
        var str = '#' + spec.ds._formId + ' label[for="' + spec.ds['_objRequestName']+ '[' + json.fieldName + ']"]';
        var element = $(str);
        if(element.length == 0) {
            throw 'Could not find the element "' + str + '" to show the form error: "' + json.message;
        }
        element.append(
            '<em class="error">' + json.message + '</em>'
        );
    },
    fadeIn : function(spec, json) {
        this.getElement().effect('fadeIn','slow');
    }
};

ria.getExtraItemCommands = function (arCommands) {
    var extra = {};
    var name;
    var f;
    for(i in arCommands) {
        name = arCommands[i];
        f = ria.extraItemCommands[name];
        if(f == undefined) {
            throw "extra command: " + name + " not found on ria.extraCommands!";
        }
        else {
            extra[name] = ria.extraItemCommands[name];
        }
    }
    return extra;
}